package zhh.tangbao.system.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import zhh.tangbao.system.constant.DataStatus;

import java.util.Date;

/**
 * 2022/11/6
 * @author 粥灰灰
 * @version 2.0
 * 基础实体类，带有每个基本实体类的基本信息，不设置ID是因为不是所有实体都会用同一种类型的主键
 * 且成员属性应该采用protected修饰，方便子类直接访问
 */

public class DaoEntity {

    /** 记录创建的时间戳 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date recordTime;

    /** 创建该条记录的用户id */
    protected String recordUserId;

    /** 更新记录的时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date updateTime;

    /** 更新记录的用户id */
    protected String updateUserId;

    /** 记录的状态，采用逻辑删除 */
    protected Integer dataStatus;

    public Date getRecordTime() {
        return recordTime;
    }

    public DaoEntity setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
        return this;
    }

    public String getRecordUserId() {
        return recordUserId;
    }

    public DaoEntity setRecordUserId(String recordUserId) {
        this.recordUserId = recordUserId;
        return this;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public DaoEntity setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
        return this;
    }

    public String getUpdateUserId() {
        return updateUserId;
    }

    public DaoEntity setUpdateUserId(String updateUserId) {
        this.updateUserId = updateUserId;
        return this;
    }

    public Integer getDataStatus() {
        return dataStatus;
    }

    public DaoEntity setDataStatus(Integer dataStatus) {
        this.dataStatus = dataStatus;
        return this;
    }

    public DaoEntity setBaseCreateInfo(String recordUserId, Integer dataStatus) {
        this.recordUserId = recordUserId;
        this.recordTime = new Date();
        this.dataStatus = dataStatus;
        return this;
    }

    public DaoEntity setBaseCreateInfo(String recordUserId, Date recordTime, Integer dataStatus) {
        this.recordUserId = recordUserId;
        this.recordTime = recordTime;
        this.dataStatus = dataStatus;
        return this;
    }

    public DaoEntity setBaseCreateInfo(String recordUserId) {
        this.recordUserId = recordUserId;
        this.recordTime = new Date();
        this.dataStatus = DataStatus.ENABLE;
        return this;
    }

    public DaoEntity setUpdateInfo(String updateUserId) {
        this.updateUserId = updateUserId;
        this.updateTime = new Date();
        return this;
    }

    public DaoEntity setUpdateInfo(String updateUserId, Date now) {
        this.updateUserId = updateUserId;
        this.updateTime = now;
        return this;
    }

    public DaoEntity setUpdateInfo(String updateUserId, Integer dataStatus) {
        this.updateUserId = updateUserId;
        this.dataStatus = dataStatus;
        this.updateTime = new Date();
        return this;
    }

    public DaoEntity setUpdateInfo(String updateUserId, Date now, Integer dataStatus) {
        this.updateUserId = updateUserId;
        this.updateTime = now;
        this.dataStatus = dataStatus;
        return this;
    }

    public DaoEntity setEnableInfo(String recordUserId) {
        this.recordUserId = recordUserId;
        this.recordTime = new Date();
        this.dataStatus = DataStatus.ENABLE;
        return this;
    }
}
